<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<jsp:directive.page import="com.xr.common.CommUtil"/>
<jsp:directive.page import="com.bstek.dorado.data.db.*"/>
<jsp:directive.page import="com.bstek.dorado.utils.variant.VariantSet"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
<script language="javascript" src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/jquery1.8.2.min.js"></script>
 <script  src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/highcharts2.3.5.js"></script>
<script   src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/exporting2.3.5.js"></script>
<script type="text/javascript"> 
		 	<%
		 	DBStatement dbs=new DBStatement();
	    Map<String,String> hm=new HashMap();
		String qjD="",jbD="",ccD="",sql="";
		String dxqjD="";//带薪请假
		String cdztD="";//迟到早退
		String kgD="";//矿工
		String wcbbD="";//外出报备 
		String empId=request.getParameter("employee_id");
		String year=request.getParameter("year");
			
			 
	sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.pay_or_cut=0 and cd.hritems_id in(select hritems_id from pb_hritems_type where type_id=210) ";
		 
			if(empId!=null&&!empId.equals("")){
				//sql+=" and exists(select 1 from org_dept dept where dept.dr=0 start with dept.dept_id=oos.dept_id CONNECT BY prior dept.dept_id=dept.super_dept_id)";			
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<=cd.work_day and cd.work_day <=to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
			List list=dbs.queryForList();
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i); 
			  dxqjD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],"; 
			   
			} 
			if(list.size()>0) dxqjD=dxqjD.substring(0,dxqjD.length()-1);
			//////////////////
			
			sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.pay_or_cut=2 and cd.hritems_id in(select hritems_id from pb_hritems_type where type_id=210) ";
	
			if(empId!=null&&!empId.equals("")){
				//sql+=" and exists(select 1 from org_dept dept where dept.dr=0 start with dept.dept_id=oos.dept_id CONNECT BY prior dept.dept_id=dept.super_dept_id)";			
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<cd.work_day and cd.work_day <to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
		   list=dbs.queryForList();
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
				  qjD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],"; 
			} 
			if(list.size()>0) qjD=qjD.substring(0,qjD.length()-1);
			//////////////////////////////////////////////////////////////// 加班
			hm=new HashMap();
					 
	sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.hritems_id in(select hritems_id from pb_hritems_type where type_id=211) ";
		
			
			if(empId!=null&&!empId.equals("")){
				//sql+=" and exists(select 1 from org_dept dept where dept.dr=0 start with dept.dept_id=oos.dept_id CONNECT BY prior dept.dept_id=dept.super_dept_id)";
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<cd.work_day and cd.work_day <to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
			 list=dbs.queryForList();
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
			   jbD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],";  
			}
			 
			if(list.size()>0) jbD=jbD.substring(0,jbD.length()-1);
			
			hm=new HashMap();
			
			
	sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.hritems_id in(select hritems_id from pb_hritems_type where type_id=212) ";
		
			
			if(empId!=null&&!empId.equals("")){
				//sql+=" and exists(select 1 from org_dept dept where dept.dr=0 start with dept.dept_id=oos.dept_id CONNECT BY prior dept.dept_id=dept.super_dept_id)";			
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<cd.work_day and cd.work_day <to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
			 list=dbs.queryForList();
			//if(list.size()==0){out.write("</script><body>无数据被统计！<body>"); return;}
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
			  ccD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],";  
			}
			  
			if(list.size()>0) ccD=ccD.substring(0,ccD.length()-1);
			
			
				hm=new HashMap();
			
			
	sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.hritems_id in(2530,2531) ";
		
			
			if(empId!=null&&!empId.equals("")){
				//sql+=" and exists(select 1 from org_dept dept where dept.dr=0 start with dept.dept_id=oos.dept_id CONNECT BY prior dept.dept_id=dept.super_dept_id)";			
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<cd.work_day and cd.work_day <to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
			 list=dbs.queryForList(); 
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
			  cdztD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],";  
			}
			  
			if(list.size()>0) cdztD=cdztD.substring(0,cdztD.length()-1);
			
		 	hm=new HashMap(); 
	sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.hritems_id in(2532) ";
		
			if(empId!=null&&!empId.equals("")){
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<cd.work_day and cd.work_day <to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
			 list=dbs.queryForList(); 
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
			  kgD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],";  
			}
			  
			if(list.size()>0) kgD=kgD.substring(0,kgD.length()-1);
			 
			 
			hm=new HashMap(); 
	sql="select to_char(cd.work_day,'yyyyMMdd') ymd from org_onoff_station oos,cw_detail cd where"
	 +" oos.onoff_station_id=cd.onoff_station_id and cd.dr=0 and cd.hritems_id in(2533) ";
		
			if(empId!=null&&!empId.equals("")){
				sql+=" and oos.employee_id="+empId;
			}
			if(year!=null&&!year.equals("")){
				sql+=" and to_date('"+year+"0101','yyyy-mm-dd')<cd.work_day and cd.work_day <to_date('"+year+"1231','yyyy-mm-dd') ";			
			}
			dbs.setSql(sql);
			 list=dbs.queryForList(); 
			for(int i=0;i<list.size();i++){
			  VariantSet vs=(VariantSet)list.get(i);
			  wcbbD+="["+vs.getString(0).substring(6,8)+","+vs.getString(0).substring(4,6)+"],";  
			}
			  
			if(list.size()>0) wcbbD=wcbbD.substring(0,wcbbD.length()-1); 
			 
			  
			 
			 list=null;
			 hm=null;
			 dbs.close(); 
		%>
		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container', 
						defaultSeriesType: 'scatter',
						zoomType: 'xy'
					},
					title: {
						text: '<%=year%>年分散图'
					},
					subtitle: {
						text: ''
					},
					xAxis: {
						title: {
							enabled: true,
							text: '1-31日'
						},
						tickPixelInterval: 30,
						
						startOnTick: false,
						endOnTick: true,
						showLastLabel: true,
						gridLineWidth: 1,
						min: 1,
						max: 31
					},
					yAxis: {
						title: {
							text: '1-12月份'
						},
						min: 1,
						max: 12,
						gridLineWidth: 1,
						tickPixelInterval: 50
					},
					tooltip: {
						formatter: function() {
				                return ''+
								this.y +'月-'+ this.x +'日 '+this.series.name;
						}
					},
					legend: {
						layout: 'vertical',
						align: 'left',
						verticalAlign: 'top',
						x: 100,
						y: 70,
						floating: false,
						backgroundColor: '#FFFFFF',
						borderWidth: 1
					},
					plotOptions: {
						scatter: {
							marker: {
								radius: 5,
								states: {
									hover: {
										enabled: true,
										lineColor: 'rgb(100,100,100)'
									}
								}
							},
							states: {
								hover: {
									marker: {
										enabled: false
									}
								}
							}
						}
					},
					series: [{
						name: '请假(带薪)',
						color: 'rgba(250, 1, 252, 1.5)',
						data: [<%=dxqjD%>]
				
					},{
						name: '请假(扣薪)',
						color: 'rgba(223, 83, 83, 1.5)',
						data: [<%=qjD%>]
				
					}, {
						name: '加班',
						color: 'rgba(119, 152, 191, 1.5)',
						data: [<%=jbD%>]
				
					},{
						name: '出差',
						color: 'rgba(183, 91, 122, 1.5)',
						data: [<%=ccD%>]
				
					},{
						name: '迟到或早退',
						color: 'rgba(53, 230,82, 1.5)',
						data: [<%=cdztD%>]
				
					},{
						name: '旷工',
						color: 'rgba(3, 252, 22, 1.5)',
						data: [<%=kgD%>]
				
					},{
						name: '外出报备',
						color: 'rgba(3, 180, 252, 1.5)',
						data: [<%=wcbbD%>]
				
					}]
				});
				
				
			});
				
		</script>

  </head>
  
  <body>
    <div id="container" style="width: 100%; height: 100%; margin: 0 auto"></div>

  </body>
</html>
